import request from '@/utils/request'

// 查询采购货品列表
export function listPurchaseGoods(query) {
  return request({
    url: '/crm/purchaseGoods/list',
    method: 'get',
    params: query
  })
}

export function listByPurchase(id) {
  return request({
    url: '/crm/purchaseGoods/listByPurchase?id='+id,
    method: 'get'
  })
}

// 查询采购列表-关联商品库存
export function loadListRelInventory(id) {
  return request({
    url: '/crm/purchaseGoods/loadListRelInventory?purchaseOrderId='+id,
    method: 'get'
  })
}

// 同步采购库存
export function syncInventory(id) {
  return request({
    url: '/crm/purchaseGoods/syncInventory?purchaseOrderId=' + id,
    method: 'get'
  })
}


// 查询采购货品详细
export function getPurchaseGoods(id) {
  return request({
    url: '/crm/purchaseGoods/' + id,
    method: 'get'
  })
}

// 新增采购货品
export function addPurchaseGoods(data) {
  return request({
    url: '/crm/purchaseGoods',
    method: 'post',
    data: data
  })
}

// 新增采购货品
export function savePurchaseGoods(data,purchaseOrderId) {
  return request({
    url: '/crm/purchaseGoods/save?purchaseOrderId='+purchaseOrderId,
    method: 'post',
    data: data
  })
}

// 修改采购货品
export function updatePurchaseGoods(data) {
  return request({
    url: '/crm/purchaseGoods',
    method: 'put',
    data: data
  })
}

// 删除采购货品
export function delPurchaseGoods(id) {
  return request({
    url: '/crm/purchaseGoods/' + id,
    method: 'delete'
  })
}
